package nl.vu.few.ibivu.biomodels.client.ui.cytoscapeweb;

import com.google.gwt.core.client.JsArray;

public class CytoscapeWebPresetLayout extends CytoscapeWebLayout {

	protected CytoscapeWebPresetLayout() {}
	
	public static CytoscapeWebPresetLayout createFromNodes(boolean fitToScreen, JsArray<CytoscapeWebNode> nodes) {
		CytoscapeWebPresetLayout obj = (CytoscapeWebPresetLayout) CytoscapeWebPresetLayout.createObject();
		obj.setName("Preset");
		obj.setFitToScreen(fitToScreen).setPointsFromNodes(nodes);
		return obj;
	}
	
	public static CytoscapeWebPresetLayout create(boolean fitToScreen, JsArray<CytoscapeWebPoint> points) {
		CytoscapeWebPresetLayout obj = (CytoscapeWebPresetLayout) CytoscapeWebPresetLayout.createObject();
		obj.setName("Preset");
		obj.setFitToScreen(fitToScreen).setPoints(points);
		return obj;
	}
	
	public final native boolean isFitToScreen() /*-{
		if (!this.options)
			return false;
		return this.options.fitToScreen;
	}-*/;
	
	public final native CytoscapeWebPresetLayout setFitToScreen(boolean value) /*-{
		if (!this.options)
			this.options = {}
		this.options.fitToScreen = value;
		return this;
	}-*/;

	public final native JsArray<CytoscapeWebPoint> getPoints() /*-{
		if (!this.options)
			return null;
		return this.options.points;
	}-*/;
	
	public final native CytoscapeWebPresetLayout setPoints(JsArray<CytoscapeWebPoint> points) /*-{
		if (!this.options)
			this.options = {};
		this.options.points = points;
		return this;
	}-*/;
	
	public final native CytoscapeWebPresetLayout setPointsFromNodes(JsArray<CytoscapeWebNode> nodes) /*-{
		if (!this.options)
			this.options = {};
		this.options.points = new $wnd.Array();
		for (var i = 0, len = nodes.length; i < len; ++i) {
			this.options.points.push(@nl.vu.few.ibivu.biomodels.client.ui.cytoscapeweb.CytoscapeWebPoint::create(Lnl/vu/few/ibivu/biomodels/client/ui/cytoscapeweb/CytoscapeWebNode;)(nodes[i]));
		}
		return this;
	}-*/;
}
